package com.bestv.bsr.core.service.impl.hb.fallback;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.bestv.remote.context.MethodContext;
import com.bestv.remote.context.ParamContext;
import com.bestv.remote.context.ServerContext;
import com.bestv.remote.interfaces.BlockHandler;
import com.bestv.remote.interfaces.FallbackHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 湖北移动 降级熔断处理
 *
 * @author taojiacheng
 */
@Service
@Slf4j
public class HBFallbackHandler implements FallbackHandler<String>, BlockHandler<String> {

    @Override
    public String handlerBlock(ServerContext serverContext, MethodContext methodContext,
                               ParamContext paramContext, BlockException blockException) {
        log.info("------湖北第三方推荐接口<已经熔断>进入, 返回空对象-----");
        return "|";
    }

    @Override
    public String handlerFallback(ServerContext serverContext, MethodContext methodContext,
                                  ParamContext paramContext, Throwable throwable) {
        log.info("-----湖北第三方推荐接口请求<异常>, 进入返回空对象-----");
        return "|";
    }
}
